#pragma once
#include "Header.h"
#include "ntstruct.h"
#include "ntfunction.h"
#include <ntimage.h>

typedef struct _SERVICE_TABLE_ENTRY
{
    ULONG dwServiceId;
    PVOID lpServiceProc;
    CHAR strServiceName[64];
} SERVICE_TABLE_ENTRY, * PSERVICE_TABLE_ENTRY;

typedef struct _SERVICE_TABLE
{
    SIZE_T EntrySize;
    PSERVICE_TABLE_ENTRY Table;
} SERVICE_TABLE, * PSERVICE_TABLE;

ULONG_PTR ImGetImageBase(_In_opt_ const char* ImageName, _Out_opt_ PSIZE_T SizeOfImage);

NTSTATUS Fs2OpenFileForRead(IN PUNICODE_STRING lpusFilePath, OUT PHANDLE lphFile, OUT PIO_STATUS_BLOCK lpIoStatusBlock);
NTSTATUS Fs2OpenFileForWrite(IN PUNICODE_STRING lpusFilePath, OUT PHANDLE lphFile, OUT PIO_STATUS_BLOCK lpIoStatusBlock);
NTSTATUS Fs2CopyFile(IN PUNICODE_STRING lpusDstFile, IN PUNICODE_STRING lpusSrcFile);
NTSTATUS Fs2ReadFile(IN PUNICODE_STRING lpusSrcFile, OUT PVOID lpBuff, IN ULONG dwBuffSize, OUT PLARGE_INTEGER lpReturnSize);

PSYSTEM_SERVICE_DISPATCH_TABLE Mm2FindKeServiceDescriptorTable();
PSYSTEM_SERVICE_DISPATCH_TABLE Mm2FindWin32kServiceDescriptorTable();
PSERVICE_TABLE Mm2EnumServiceTable(IN PSYSTEM_SERVICE_DISPATCH_TABLE lpKeServiceDescriptorTable);
void Mm2FreeServiceTable(IN PSERVICE_TABLE lpServiceTable);
PVOID Mm2GetServiceProc(IN PSERVICE_TABLE lpServiceTable, IN PCSTR lpszFunctionName);

PSERVICE_TABLE Mm2EnumWin32kServiceTable(IN PSYSTEM_SERVICE_DISPATCH_TABLE lpWin32kServiceDescriptorTable);
void Mm2FreeWin32kServiceTable(IN PSERVICE_TABLE lpWin32kServiceTable);
